<script>
var DialogReviewerWelcome = {
    data: {
        dialogReviewerWelcomeVisible: false,
        dialogReviewerWelcome2Visible: false,
        dialogReviewerWelcome2FileReadCompleteTime: null,
        dialogReviewerWelcome2CurrentTime: null,
        dialogReviewerWelcome2FileUrl: '/libs/pdfjs/viewer.html?file_url=/docs/中路建协行发[2024]13号 关于印发《中国公路建设行业协会科学技术奖管理办法》及实施细则的通知.pdf',
        dialogReviewerWelcome3Visible: false,
    },
    computed: {
        dialogReviewerWelcomeDisplayData() {
            return {
                reviewerName: this.reviewerName,
                projectCount: this.projectPageData.length,
                reviewStartTime: moment(this.reviewBeginAt).format('YYYY年M月D日 HH:mm'),
                reviewEndTime: moment(this.reviewEndAt).format('YYYY年M月D日 HH:mm'),
            }
        },
        canGoToDialogReviewerWelcome3() {
            if (this.dialogReviewerWelcome2CurrentTime && this.dialogReviewerWelcome2FileReadCompleteTime) {
                return this.dialogReviewerWelcome2FileReadCompleteTime.isBefore(this.dialogReviewerWelcome2CurrentTime)
            }
            return false
        },
        dialogReviewerWelcome2CountdownText() {
            var t1 = this.dialogReviewerWelcome2CurrentTime
            var t2 = this.dialogReviewerWelcome2FileReadCompleteTime
            if (t1 && t2 && t1.isBefore(t2)) {
                var diffInSeconds = Math.floor((t2 - t1) / 1000)
                if (diffInSeconds < 0) {
                    return '0:00'
                }
                var minutePart = Math.floor(diffInSeconds / 60)
                var secondPart = diffInSeconds % 60
                if (secondPart < 10) {
                    secondPart = '0' + secondPart
                }
                return minutePart + ':' + secondPart
            }
            return '3:00'
        },
        managementFileReadCompleteTimeCountdown() {
            if (this.managementFileReadCompleteTime) {
                var minutePart = this.managementFileReadCompleteTime.diff(moment())
            }
            return null
        },
    },
    methods: {
        showReviewerWelcomeDialog() {
            this.dialogReviewerWelcomeVisible = true
            axios.get('/api/review/report-welcome-dialog-shown')
        },
        showReviewerWelcome2Dialog() {
            this.dialogReviewerWelcomeVisible = false
            this.dialogReviewerWelcome2Visible = true
            this.dialogReviewerWelcome2FileReadCompleteTime = moment().add('3', 'm')
            setInterval(() => {
                this.dialogReviewerWelcome2CurrentTime = moment()
            }, 1000)
        },
        showReviewerWelcome3Dialog() {
            this.dialogReviewerWelcome2Visible = false
            this.dialogReviewerWelcome3Visible = true
        },
        dismissWelcomeDialog() {
            this.dialogReviewerWelcomeVisible = false
            this.dialogReviewerWelcome2Visible = false
            this.dialogReviewerWelcome3Visible = false
        },
    },
}
</script>